// pages/policydetails/policydetails.js
var app = getApp()
var util = require('../../utils/util.js');
var commonService = require('../../services/commonService.js');
var newsService = require('../../services/newsService.js');
var WxParse = require('../../wxParse/wxParse.js');
Page({
  data: {},
  onLoad: function (options) {

    // 页面初始化 options为页面跳转所带来的参数
    app.globalData.newsType = options.newsType
    this.setData({
      id: options.id
    })
    this.getDetail()
  },
  onReady: function () {
    // 页面渲染完成
  },
  onShow: function () {
    // 页面显示
  },
  onHide: function () {
    // 页面隐藏
  },
  onUnload: function () {
    // 页面关闭
  },
  getDetail: function () {
    var that = this;
    newsService.getNewsDetail({
      id: that.data.id,
      success: function (res) {
        res.created_at = util.makeDateTimeToPretty(new Date(res.created_at.replace(/-/g, "/")), true);
        that.setData({
          content: res
        })
        WxParse.wxParse('description', 'html', that.data.content.description, that, 5);
      }
    });
  },
  backTopPrevNavigate: function () {
    wx.navigateBack()
  }
})